Fix doubled node_modules path in sourcemap sources for natively-resolved civet packages#1890
Draft
Fix doubled node_modules path in sourcemap sources for natively-resolved civet packages#1890
node_modules path in sourcemap sources for natively-resolved civet packages#1890Conversation
…es packages Agent-Logs-Url: https://github.com/DanielXMoore/Civet/sessions/5f4de426-a58f-4a8e-a62b-abd12d9b11f3 Co-authored-by: STRd6 <18894+STRd6@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix sourcemap source attribute for civet file in node_modules package
Fix doubled Apr 1, 2026
node_modules path in sourcemap sources for natively-resolved civet packages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Civet files loaded from
node_modulespackages (where the bundler resolves the file natively, not through the plugin'sresolveIdhook) produced malformed sourcemap source paths like../node_modules/pkg/lib/node_modules/pkg/lib/math.civetinstead of../node_modules/pkg/lib/math.civet.Root cause
Two distinct load paths exist in the plugin:
resolveIdappendsoutExt, e.g..jsx): these land in a plugin namespace and the bundler uses source paths as-is —path.relative(outDir, filename)is correct.idhas nooutExtsuffix, e.g. anode_modulespackage whosemainis a.civetfile): the bundler resolves sourcemapsourcesentries relative to the input file's directory. A path like../node_modules/pkg/index.civetresolved fromnode_modules/pkg/becomesnode_modules/node_modules/pkg/index.civet.Changes
source/unplugin/unplugin.civet— Discriminate onid.endsWith(outExt): for natively-resolved files usepath.relative(path.dirname(filename), filename)(basename relative to input dir) so the bundler resolves it correctly; keep existing logic for plugin-resolved virtual files.test/integration.civet— Add integration test that creates a minimalnode_modulesfixture, builds with esbuild, and asserts the sourcemapsourcesentry is../node_modules/test-civet-pkg/index.civet.integration/example/build-node-modules.civet/integration/example/source/uses-pkg.civet— Supporting fixtures for the new test.